

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/broswer.jpg">
  <link rel="icon" href="/img/broswer.jpg">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="Feng Zikai">
  <meta name="keywords" content="">
  
    <meta name="description" content="虽然fluid 主题已经非常好看了，但我依旧可以通过一些简单的操作，让你的博客更加易用（更花里胡哨和装逼）:smile: 1. Fluid 页脚增加网站运行时长主题预览网站中有了很详细的介绍，这里就不在重复了 配置链接，效果如下：  2. markdown 使用emoji默认不支持输入emoji表情，我们可以通过hexo-filter-emoji插件实现 1npm install hexo-fil">
<meta property="og:type" content="article">
<meta property="og:title" content="fluid主题优化">
<meta property="og:url" content="http://example.com/2022/03/17/fluid%E4%B8%BB%E9%A2%98%E4%BC%98%E5%8C%96/index.html">
<meta property="og:site_name" content="F7kyyy的博客">
<meta property="og:description" content="虽然fluid 主题已经非常好看了，但我依旧可以通过一些简单的操作，让你的博客更加易用（更花里胡哨和装逼）:smile: 1. Fluid 页脚增加网站运行时长主题预览网站中有了很详细的介绍，这里就不在重复了 配置链接，效果如下：  2. markdown 使用emoji默认不支持输入emoji表情，我们可以通过hexo-filter-emoji插件实现 1npm install hexo-fil">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://example.com/img/article/hexo_fluid.png">
<meta property="article:published_time" content="2022-03-17T15:33:12.000Z">
<meta property="article:modified_time" content="2023-07-09T13:47:12.000Z">
<meta property="article:author" content="Feng Zikai">
<meta property="article:tag" content="hexo">
<meta property="article:tag" content="花里胡哨">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="http://example.com/img/article/hexo_fluid.png">
  
  
  
  <title>fluid主题优化 - F7kyyy的博客</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  



  
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css">



  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"example.com","root":"/","version":"1.9.5-a","typing":{"enable":true,"typeSpeed":60,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading1.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":{"measurement_id":null},"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml","include_content_in_search":true};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 6.3.0"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 70vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>F7kyyy&#39;s blog</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                <span>首页</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                <span>归档</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                <span>分类</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                <span>标签</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                <span>关于</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/links/">
                <i class="iconfont icon-link-fill"></i>
                <span>友链</span>
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              <i class="iconfont icon-search"></i>
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">
              <i class="iconfont icon-dark" id="color-toggle-icon"></i>
            </a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/img/default.png') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="fluid主题优化"></span>
          
        </div>

        
          
  <div class="mt-3">
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2022-03-17 23:33" pubdate>
          2022年3月17日 晚上
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          9.4k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          79 分钟
        
      </span>
    

    
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <h1 id="seo-header">fluid主题优化</h1>
            
            
              <div class="markdown-body">
                
                <p>虽然fluid 主题已经非常好看了，但我依旧可以通过一些简单的操作，让你的博客更加易用（更花里胡哨和装逼）:smile:</p>
<h2 id="1-Fluid-页脚增加网站运行时长"><a href="#1-Fluid-页脚增加网站运行时长" class="headerlink" title="1. Fluid 页脚增加网站运行时长"></a>1. Fluid 页脚增加网站运行时长</h2><p>主题预览网站中有了很详细的介绍，这里就不在重复了</p>
<p><a target="_blank" rel="noopener" href="https://hexo.fluid-dev.com/posts/fluid-footer-custom/">配置链接</a>，效果如下：</p>
<p><img src="https://cdn.jsdelivr.net/gh/F7kyyy/picture@main/img/202203261337892.png" srcset="/img/loading1.gif" lazyload alt="202203172342237"></p>
<h2 id="2-markdown-使用emoji"><a href="#2-markdown-使用emoji" class="headerlink" title="2. markdown 使用emoji"></a>2. markdown 使用emoji</h2><p>默认不支持输入emoji表情，我们可以通过hexo-filter-emoji插件实现</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">npm install hexo-filter-emoji<br></code></pre></td></tr></table></figure>

<p>之后在hexo配置文件，_config.html中添加</p>
<figure class="highlight yml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs yml"><span class="hljs-comment">## hexo-filter-emoji</span><br><span class="hljs-attr">emoji:</span><br>  <span class="hljs-attr">enable:</span> <span class="hljs-literal">true</span><br>  <span class="hljs-attr">className:</span> <span class="hljs-string">github-emoji</span><br>  <span class="hljs-attr">styles:</span><br>  <span class="hljs-attr">customEmojis:</span><br></code></pre></td></tr></table></figure>

<p>效果如下:thumbsup::</p>
<p><img src="https://cdn.jsdelivr.net/gh/F7kyyy/picture@main/img/202203261338900.png" srcset="/img/loading1.gif" lazyload alt="202203172346789"></p>
<h2 id="3-使用Tidio进行实时交流"><a href="#3-使用Tidio进行实时交流" class="headerlink" title="3. 使用Tidio进行实时交流"></a>3. 使用Tidio进行实时交流</h2><p> Tidio是一个客服服务平台，可以在blog中实现Live Chat,存在网页端和移动端，可以及时回复消息，同时免费功能足够我们使用，效果如下：</p>
<p><img src="https://cdn.jsdelivr.net/gh/F7kyyy/picture@main/img/202203261337746.png" srcset="/img/loading1.gif" lazyload alt="202203191703130"></p>
<img src="https://cdn.jsdelivr.net/gh/F7kyyy/picture@main/img/202203261338806.png" srcset="/img/loading1.gif" lazyload alt="202203191703265" style="zoom:50%;" />

<ul>
<li><p>首先进入 <a target="_blank" rel="noopener" href="https://www.tidio.com/">Tidio 官网</a> 进行注册，可能需要魔法上网</p>
</li>
<li><p>选择live chat 在settings 中调整自己的语句和外观</p>
</li>
<li><p>在setting-&gt;developver中复制public key</p>
<img src="https://cdn.jsdelivr.net/gh/F7kyyy/picture@main/img/202207031414402.png" srcset="/img/loading1.gif" lazyload alt="202203191711294" style="zoom:50%;" />
</li>
<li><p>在主题的配置文件中添加</p>
<figure class="highlight yml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs yml"><span class="hljs-comment"># Tidio online chat</span><br><span class="hljs-attr">tidio:</span><br>  <span class="hljs-attr">enable:</span> <span class="hljs-literal">true</span><br>  <span class="hljs-attr">key:</span> <span class="hljs-string">your</span> <span class="hljs-string">public</span> <span class="hljs-string">key</span><br></code></pre></td></tr></table></figure>
</li>
<li><p>更改主题文件 </p>
<p><code>/hexo-theme-fluid/layout/_partials/footer.ejs</code>中添加</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs ejs">&lt;!-- 在线通讯Tidio --&gt;<br>&lt;% if (theme.tidio.enable)&#123; %&gt;<br>	&lt;script src=&quot;//code.tidio.co/your_public_key.js&quot;&gt;&lt;/script&gt;<br>&lt;% &#125; %&gt;<br></code></pre></td></tr></table></figure>

<p><img src="https://cdn.jsdelivr.net/gh/F7kyyy/picture/img/202306262251211.png" srcset="/img/loading1.gif" lazyload alt="image-20230626225056114"></p>
</li>
<li><p>重新部署</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs bash">hexo clean<br>hexo g<br>hexo s<br></code></pre></td></tr></table></figure></li>
</ul>
<h2 id="4-添加特效，鼠标点击，背景"><a href="#4-添加特效，鼠标点击，背景" class="headerlink" title="4. 添加特效，鼠标点击，背景"></a>4. 添加特效，鼠标点击，背景</h2><p>在<code>source/js/</code>文件夹下添加自己需要的js文件<code>background.js</code>与<code>fireworks.js</code>,在主题配置中引入。</p>
<p><code>backgound.js</code> 背景添加多边形：</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-comment">// 背景线条 bynote.cn</span><br>(<span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) &#123;<br>    <span class="hljs-keyword">function</span> <span class="hljs-title function_">getAttributeOrDefault</span>(<span class="hljs-params">element, attribute, defaultValue</span>) &#123;<br>        <span class="hljs-keyword">return</span> element.<span class="hljs-title function_">getAttribute</span>(attribute) || defaultValue;<br>    &#125;<br><br>    <span class="hljs-keyword">function</span> <span class="hljs-title function_">getElementsByTagName</span>(<span class="hljs-params">tagName</span>) &#123;<br>        <span class="hljs-keyword">return</span> <span class="hljs-variable language_">document</span>.<span class="hljs-title function_">getElementsByTagName</span>(tagName);<br>    &#125;<br><br>    <span class="hljs-keyword">function</span> <span class="hljs-title function_">getOptions</span>(<span class="hljs-params"></span>) &#123;<br>        <span class="hljs-keyword">var</span> scripts = <span class="hljs-title function_">getElementsByTagName</span>(<span class="hljs-string">&quot;script&quot;</span>);<br>        <span class="hljs-keyword">var</span> scriptCount = scripts.<span class="hljs-property">length</span>;<br>        <span class="hljs-keyword">var</span> script = scripts[scriptCount - <span class="hljs-number">1</span>];<br>        <span class="hljs-keyword">return</span> &#123;<br>            <span class="hljs-attr">count</span>: <span class="hljs-title function_">getAttributeOrDefault</span>(script, <span class="hljs-string">&quot;count&quot;</span>, <span class="hljs-number">99</span>),<br>            <span class="hljs-attr">color</span>: <span class="hljs-title function_">getAttributeOrDefault</span>(script, <span class="hljs-string">&quot;color&quot;</span>, <span class="hljs-string">&quot;0,255,128&quot;</span>),<br>            <span class="hljs-attr">opacity</span>: <span class="hljs-title function_">getAttributeOrDefault</span>(script, <span class="hljs-string">&quot;opacity&quot;</span>, <span class="hljs-number">0.5</span>),<br>            <span class="hljs-attr">zIndex</span>: <span class="hljs-title function_">getAttributeOrDefault</span>(script, <span class="hljs-string">&quot;zIndex&quot;</span>, -<span class="hljs-number">1</span>),<br>        &#125;;<br>    &#125;<br><br>    <span class="hljs-keyword">function</span> <span class="hljs-title function_">resizeCanvas</span>(<span class="hljs-params"></span>) &#123;<br>        canvas.<span class="hljs-property">width</span> = <span class="hljs-variable language_">window</span>.<span class="hljs-property">innerWidth</span> || <span class="hljs-variable language_">document</span>.<span class="hljs-property">documentElement</span>.<span class="hljs-property">clientWidth</span> || <span class="hljs-variable language_">document</span>.<span class="hljs-property">body</span>.<span class="hljs-property">clientWidth</span>;<br>        canvas.<span class="hljs-property">height</span> = <span class="hljs-variable language_">window</span>.<span class="hljs-property">innerHeight</span> || <span class="hljs-variable language_">document</span>.<span class="hljs-property">documentElement</span>.<span class="hljs-property">clientHeight</span> || <span class="hljs-variable language_">document</span>.<span class="hljs-property">body</span>.<span class="hljs-property">clientHeight</span>;<br>    &#125;<br><br>    <span class="hljs-keyword">function</span> <span class="hljs-title function_">draw</span>(<span class="hljs-params"></span>) &#123;<br>        context.<span class="hljs-title function_">clearRect</span>(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, canvas.<span class="hljs-property">width</span>, canvas.<span class="hljs-property">height</span>);<br>        <span class="hljs-keyword">var</span> particles = [mainParticle].<span class="hljs-title function_">concat</span>(otherParticles);<br>        <span class="hljs-keyword">var</span> particle, otherParticle, distance, xDiff, yDiff, alpha, lineWidth, strokeStyle;<br>        otherParticles.<span class="hljs-title function_">forEach</span>(<span class="hljs-keyword">function</span> (<span class="hljs-params">otherParticle</span>) &#123;<br>            otherParticle.<span class="hljs-property">x</span> += otherParticle.<span class="hljs-property">xa</span>;<br>            otherParticle.<span class="hljs-property">y</span> += otherParticle.<span class="hljs-property">ya</span>;<br>            otherParticle.<span class="hljs-property">xa</span> *= otherParticle.<span class="hljs-property">x</span> &gt; canvas.<span class="hljs-property">width</span> || otherParticle.<span class="hljs-property">x</span> &lt; <span class="hljs-number">0</span> ? -<span class="hljs-number">1</span> : <span class="hljs-number">1</span>;<br>            otherParticle.<span class="hljs-property">ya</span> *= otherParticle.<span class="hljs-property">y</span> &gt; canvas.<span class="hljs-property">height</span> || otherParticle.<span class="hljs-property">y</span> &lt; <span class="hljs-number">0</span> ? -<span class="hljs-number">1</span> : <span class="hljs-number">1</span>;<br>            context.<span class="hljs-title function_">beginPath</span>();<br>            context.<span class="hljs-title function_">arc</span>(otherParticle.<span class="hljs-property">x</span>, otherParticle.<span class="hljs-property">y</span>, <span class="hljs-number">2</span>, <span class="hljs-number">0</span>, <span class="hljs-number">2</span> * <span class="hljs-title class_">Math</span>.<span class="hljs-property">PI</span>);<br>            context.<span class="hljs-property">fillStyle</span> = <span class="hljs-string">&quot;rgb(135, 206, 250)&quot;</span>;<br>            context.<span class="hljs-title function_">fill</span>();<br>            <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i &lt; particles.<span class="hljs-property">length</span>; i++) &#123;<br>                particle = particles[i];<br>                <span class="hljs-keyword">if</span> (otherParticle !== particle &amp;&amp; particle.<span class="hljs-property">x</span> !== <span class="hljs-literal">null</span> &amp;&amp; particle.<span class="hljs-property">y</span> !== <span class="hljs-literal">null</span>) &#123;<br>                    xDiff = otherParticle.<span class="hljs-property">x</span> - particle.<span class="hljs-property">x</span>;<br>                    yDiff = otherParticle.<span class="hljs-property">y</span> - particle.<span class="hljs-property">y</span>;<br>                    distance = xDiff * xDiff + yDiff * yDiff;<br>                    <span class="hljs-keyword">if</span> (distance &lt; particle.<span class="hljs-property">max</span>) &#123;<br>                        <span class="hljs-keyword">if</span> (particle === mainParticle &amp;&amp; distance &gt;= particle.<span class="hljs-property">max</span> / <span class="hljs-number">2</span>) &#123;<br>                            otherParticle.<span class="hljs-property">x</span> -= <span class="hljs-number">0.03</span> * xDiff;<br>                            otherParticle.<span class="hljs-property">y</span> -= <span class="hljs-number">0.03</span> * yDiff;<br>                        &#125;<br>                        alpha = (particle.<span class="hljs-property">max</span> - distance) / particle.<span class="hljs-property">max</span>;<br>                        lineWidth = alpha;<br>                        strokeStyle = <span class="hljs-string">&quot;rgba(&quot;</span> + options.<span class="hljs-property">color</span> + <span class="hljs-string">&quot;,&quot;</span> + (alpha + <span class="hljs-number">0.2</span>) + <span class="hljs-string">&quot;)&quot;</span>;<br>                        context.<span class="hljs-title function_">beginPath</span>();<br>                        context.<span class="hljs-property">lineWidth</span> = lineWidth;<br>                        context.<span class="hljs-property">strokeStyle</span> = strokeStyle;<br>                        context.<span class="hljs-title function_">moveTo</span>(otherParticle.<span class="hljs-property">x</span>, otherParticle.<span class="hljs-property">y</span>);<br>                        context.<span class="hljs-title function_">lineTo</span>(particle.<span class="hljs-property">x</span>, particle.<span class="hljs-property">y</span>);<br>                        context.<span class="hljs-title function_">stroke</span>();<br>                    &#125;<br>                &#125;<br>            &#125;<br>            particles.<span class="hljs-title function_">splice</span>(particles.<span class="hljs-title function_">indexOf</span>(otherParticle), <span class="hljs-number">1</span>);<br>        &#125;);<br>        <span class="hljs-title function_">requestAnimationFrame</span>(draw);<br>    &#125;<br><br>    <span class="hljs-keyword">var</span> canvas = <span class="hljs-variable language_">document</span>.<span class="hljs-title function_">createElement</span>(<span class="hljs-string">&quot;canvas&quot;</span>);<br>    <span class="hljs-keyword">var</span> options = <span class="hljs-title function_">getOptions</span>();<br>    <span class="hljs-keyword">var</span> canvasId = <span class="hljs-string">&quot;c_n&quot;</span> + options.<span class="hljs-property">count</span>;<br>    <span class="hljs-keyword">var</span> context = canvas.<span class="hljs-title function_">getContext</span>(<span class="hljs-string">&quot;2d&quot;</span>);<br>    <span class="hljs-keyword">var</span> mainParticle = &#123; <span class="hljs-attr">x</span>: <span class="hljs-literal">null</span>, <span class="hljs-attr">y</span>: <span class="hljs-literal">null</span>, <span class="hljs-attr">max</span>: <span class="hljs-number">20000</span> &#125;;<br>    <span class="hljs-keyword">var</span> otherParticles = [];<br>    <span class="hljs-keyword">var</span> requestAnimationFrame =<br>        <span class="hljs-variable language_">window</span>.<span class="hljs-property">requestAnimationFrame</span> ||<br>        <span class="hljs-variable language_">window</span>.<span class="hljs-property">webkitRequestAnimationFrame</span> ||<br>        <span class="hljs-variable language_">window</span>.<span class="hljs-property">mozRequestAnimationFrame</span> ||<br>        <span class="hljs-variable language_">window</span>.<span class="hljs-property">oRequestAnimationFrame</span> ||<br>        <span class="hljs-variable language_">window</span>.<span class="hljs-property">msRequestAnimationFrame</span> ||<br>        <span class="hljs-keyword">function</span> (<span class="hljs-params">callback</span>) &#123;<br>            <span class="hljs-variable language_">window</span>.<span class="hljs-built_in">setTimeout</span>(callback, <span class="hljs-number">1000</span> / <span class="hljs-number">45</span>);<br>        &#125;;<br>    <span class="hljs-keyword">var</span> random = <span class="hljs-title class_">Math</span>.<span class="hljs-property">random</span>;<br><br>    canvas.<span class="hljs-property">id</span> = canvasId;<br>    canvas.<span class="hljs-property">style</span>.<span class="hljs-property">cssText</span> =<br>        <span class="hljs-string">&quot;position: fixed; top: 0; left: 0; z-index: &quot;</span> +<br>        options.<span class="hljs-property">zIndex</span> +<br>        <span class="hljs-string">&quot;; opacity: &quot;</span> +<br>        options.<span class="hljs-property">opacity</span> +<br>        <span class="hljs-string">&quot;;&quot;</span>;<br>    <span class="hljs-title function_">getElementsByTagName</span>(<span class="hljs-string">&quot;body&quot;</span>)[<span class="hljs-number">0</span>].<span class="hljs-title function_">appendChild</span>(canvas);<br><br>    <span class="hljs-title function_">resizeCanvas</span>();<br>    <span class="hljs-variable language_">window</span>.<span class="hljs-title function_">addEventListener</span>(<span class="hljs-string">&quot;resize&quot;</span>, resizeCanvas);<br>    <span class="hljs-variable language_">window</span>.<span class="hljs-title function_">addEventListener</span>(<span class="hljs-string">&quot;mousemove&quot;</span>, <span class="hljs-keyword">function</span> (<span class="hljs-params">event</span>) &#123;<br>        mainParticle.<span class="hljs-property">x</span> = event.<span class="hljs-property">clientX</span>;<br>        mainParticle.<span class="hljs-property">y</span> = event.<span class="hljs-property">clientY</span>;<br>    &#125;);<br>    <span class="hljs-variable language_">window</span>.<span class="hljs-title function_">addEventListener</span>(<span class="hljs-string">&quot;mouseout&quot;</span>, <span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) &#123;<br>        mainParticle.<span class="hljs-property">x</span> = <span class="hljs-literal">null</span>;<br>        mainParticle.<span class="hljs-property">y</span> = <span class="hljs-literal">null</span>;<br>    &#125;);<br><br>    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i &lt; options.<span class="hljs-property">count</span>; i++) &#123;<br>        <span class="hljs-keyword">var</span> x = <span class="hljs-title function_">random</span>() * canvas.<span class="hljs-property">width</span>;<br>        <span class="hljs-keyword">var</span> y = <span class="hljs-title function_">random</span>() * canvas.<span class="hljs-property">height</span>;<br>        <span class="hljs-keyword">var</span> xa = <span class="hljs-number">2</span> * <span class="hljs-title function_">random</span>() - <span class="hljs-number">1</span>;<br>        <span class="hljs-keyword">var</span> ya = <span class="hljs-number">2</span> * <span class="hljs-title function_">random</span>() - <span class="hljs-number">1</span>;<br>        otherParticles.<span class="hljs-title function_">push</span>(&#123; <span class="hljs-attr">x</span>: x, <span class="hljs-attr">y</span>: y, <span class="hljs-attr">xa</span>: xa, <span class="hljs-attr">ya</span>: ya, <span class="hljs-attr">max</span>: <span class="hljs-number">6000</span> &#125;);<br>    &#125;<br><br>    <span class="hljs-built_in">setTimeout</span>(<span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) &#123;<br>        <span class="hljs-title function_">draw</span>();<br>    &#125;, <span class="hljs-number">100</span>);<br>&#125;)();<br></code></pre></td></tr></table></figure>

<p><code>fireworks.js</code> 鼠标点击气泡特效</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-keyword">class</span> <span class="hljs-title class_">Circle</span> &#123;<br>  <span class="hljs-title function_">constructor</span>(<span class="hljs-params">&#123; origin, speed, color, angle, context &#125;</span>) &#123;<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">origin</span> = origin<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">position</span> = &#123; ...<span class="hljs-variable language_">this</span>.<span class="hljs-property">origin</span> &#125;<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">color</span> = color<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">speed</span> = speed<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">angle</span> = angle<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">context</span> = context<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">renderCount</span> = <span class="hljs-number">0</span><br>  &#125;<br><br>  <span class="hljs-title function_">draw</span>(<span class="hljs-params"></span>) &#123;<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">context</span>.<span class="hljs-property">fillStyle</span> = <span class="hljs-variable language_">this</span>.<span class="hljs-property">color</span><br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">context</span>.<span class="hljs-title function_">beginPath</span>()<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">context</span>.<span class="hljs-title function_">arc</span>(<span class="hljs-variable language_">this</span>.<span class="hljs-property">position</span>.<span class="hljs-property">x</span>, <span class="hljs-variable language_">this</span>.<span class="hljs-property">position</span>.<span class="hljs-property">y</span>, <span class="hljs-number">4</span>, <span class="hljs-number">0</span>, <span class="hljs-title class_">Math</span>.<span class="hljs-property">PI</span> * <span class="hljs-number">2</span>)<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">context</span>.<span class="hljs-title function_">fill</span>()<br>  &#125;<br><br>  <span class="hljs-title function_">move</span>(<span class="hljs-params"></span>) &#123;<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">position</span>.<span class="hljs-property">x</span> = (<span class="hljs-title class_">Math</span>.<span class="hljs-title function_">sin</span>(<span class="hljs-variable language_">this</span>.<span class="hljs-property">angle</span>) * <span class="hljs-variable language_">this</span>.<span class="hljs-property">speed</span>) + <span class="hljs-variable language_">this</span>.<span class="hljs-property">position</span>.<span class="hljs-property">x</span><br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">position</span>.<span class="hljs-property">y</span> = (<span class="hljs-title class_">Math</span>.<span class="hljs-title function_">cos</span>(<span class="hljs-variable language_">this</span>.<span class="hljs-property">angle</span>) * <span class="hljs-variable language_">this</span>.<span class="hljs-property">speed</span>) + <span class="hljs-variable language_">this</span>.<span class="hljs-property">position</span>.<span class="hljs-property">y</span> + (<span class="hljs-variable language_">this</span>.<span class="hljs-property">renderCount</span> * <span class="hljs-number">0.3</span>)<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">renderCount</span>++<br>  &#125;<br>&#125;<br><br><span class="hljs-keyword">class</span> <span class="hljs-title class_">Boom</span> &#123;<br>  <span class="hljs-title function_">constructor</span>(<span class="hljs-params">&#123; origin, context, circleCount = <span class="hljs-number">16</span>, area &#125;</span>) &#123;<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">origin</span> = origin<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">context</span> = context<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">circleCount</span> = circleCount<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">area</span> = area<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">stop</span> = <span class="hljs-literal">false</span><br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">circles</span> = []<br>  &#125;<br><br>  <span class="hljs-title function_">randomArray</span>(<span class="hljs-params">range</span>) &#123;<br>    <span class="hljs-keyword">const</span> length = range.<span class="hljs-property">length</span><br>    <span class="hljs-keyword">const</span> randomIndex = <span class="hljs-title class_">Math</span>.<span class="hljs-title function_">floor</span>(length * <span class="hljs-title class_">Math</span>.<span class="hljs-title function_">random</span>())<br>    <span class="hljs-keyword">return</span> range[randomIndex]<br>  &#125;<br><br><span class="hljs-title function_">randomColor</span>(<span class="hljs-params"></span>) &#123;<br>  <span class="hljs-keyword">const</span> range = [<span class="hljs-string">&#x27;FF5733&#x27;</span>, <span class="hljs-string">&#x27;FFC300&#x27;</span>, <span class="hljs-string">&#x27;DAF7A6&#x27;</span>, <span class="hljs-string">&#x27;C70039&#x27;</span>, <span class="hljs-string">&#x27;900C3F&#x27;</span>, <span class="hljs-string">&#x27;581845&#x27;</span>, <span class="hljs-string">&#x27;00FFFF&#x27;</span>, <span class="hljs-string">&#x27;FF00FF&#x27;</span>, <span class="hljs-string">&#x27;FFFF00&#x27;</span>]<br>  <span class="hljs-keyword">return</span> <span class="hljs-string">&#x27;#&#x27;</span> + <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">randomArray</span>(range)<br>&#125;<br><br>  <span class="hljs-title function_">randomRange</span>(<span class="hljs-params">start, end</span>) &#123;<br>    <span class="hljs-keyword">return</span> (end - start) * <span class="hljs-title class_">Math</span>.<span class="hljs-title function_">random</span>() + start<br>  &#125;<br><br>  <span class="hljs-title function_">init</span>(<span class="hljs-params"></span>) &#123;<br>    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">0</span>; i &lt; <span class="hljs-variable language_">this</span>.<span class="hljs-property">circleCount</span>; i++) &#123;<br>      <span class="hljs-keyword">const</span> circle = <span class="hljs-keyword">new</span> <span class="hljs-title class_">Circle</span>(&#123;<br>        <span class="hljs-attr">context</span>: <span class="hljs-variable language_">this</span>.<span class="hljs-property">context</span>,<br>        <span class="hljs-attr">origin</span>: <span class="hljs-variable language_">this</span>.<span class="hljs-property">origin</span>,<br>        <span class="hljs-attr">color</span>: <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">randomColor</span>(),<br>        <span class="hljs-attr">angle</span>: <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">randomRange</span>(<span class="hljs-title class_">Math</span>.<span class="hljs-property">PI</span> - <span class="hljs-number">1</span>, <span class="hljs-title class_">Math</span>.<span class="hljs-property">PI</span> + <span class="hljs-number">1</span>),<br>        <span class="hljs-attr">speed</span>: <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">randomRange</span>(<span class="hljs-number">1</span>, <span class="hljs-number">3</span>)<br>      &#125;)<br>      <span class="hljs-variable language_">this</span>.<span class="hljs-property">circles</span>.<span class="hljs-title function_">push</span>(circle)<br>    &#125;<br>  &#125;<br><br>  <span class="hljs-title function_">move</span>(<span class="hljs-params"></span>) &#123;<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">circles</span>.<span class="hljs-title function_">forEach</span>(<span class="hljs-function">(<span class="hljs-params">circle, index</span>) =&gt;</span> &#123;<br>      <span class="hljs-keyword">if</span> (circle.<span class="hljs-property">position</span>.<span class="hljs-property">x</span> &gt; <span class="hljs-variable language_">this</span>.<span class="hljs-property">area</span>.<span class="hljs-property">width</span> || circle.<span class="hljs-property">position</span>.<span class="hljs-property">y</span> &gt; <span class="hljs-variable language_">this</span>.<span class="hljs-property">area</span>.<span class="hljs-property">height</span>) &#123;<br>        <span class="hljs-keyword">return</span> <span class="hljs-variable language_">this</span>.<span class="hljs-property">circles</span>.<span class="hljs-title function_">splice</span>(index, <span class="hljs-number">1</span>)<br>      &#125;<br>      circle.<span class="hljs-title function_">move</span>()<br>    &#125;)<br>    <span class="hljs-keyword">if</span> (<span class="hljs-variable language_">this</span>.<span class="hljs-property">circles</span>.<span class="hljs-property">length</span> == <span class="hljs-number">0</span>) &#123;<br>      <span class="hljs-variable language_">this</span>.<span class="hljs-property">stop</span> = <span class="hljs-literal">true</span><br>    &#125;<br>  &#125;<br><br>  <span class="hljs-title function_">draw</span>(<span class="hljs-params"></span>) &#123;<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">circles</span>.<span class="hljs-title function_">forEach</span>(<span class="hljs-function"><span class="hljs-params">circle</span> =&gt;</span> circle.<span class="hljs-title function_">draw</span>())<br>  &#125;<br>&#125;<br><br><span class="hljs-keyword">class</span> <span class="hljs-title class_">CursorSpecialEffects</span> &#123;<br>  <span class="hljs-title function_">constructor</span>(<span class="hljs-params"></span>) &#123;<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">computerCanvas</span> = <span class="hljs-variable language_">document</span>.<span class="hljs-title function_">createElement</span>(<span class="hljs-string">&#x27;canvas&#x27;</span>)<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">renderCanvas</span> = <span class="hljs-variable language_">document</span>.<span class="hljs-title function_">createElement</span>(<span class="hljs-string">&#x27;canvas&#x27;</span>)<br><br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">computerContext</span> = <span class="hljs-variable language_">this</span>.<span class="hljs-property">computerCanvas</span>.<span class="hljs-title function_">getContext</span>(<span class="hljs-string">&#x27;2d&#x27;</span>)<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">renderContext</span> = <span class="hljs-variable language_">this</span>.<span class="hljs-property">renderCanvas</span>.<span class="hljs-title function_">getContext</span>(<span class="hljs-string">&#x27;2d&#x27;</span>)<br><br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">globalWidth</span> = <span class="hljs-variable language_">window</span>.<span class="hljs-property">innerWidth</span><br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">globalHeight</span> = <span class="hljs-variable language_">window</span>.<span class="hljs-property">innerHeight</span><br><br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">booms</span> = []<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">running</span> = <span class="hljs-literal">false</span><br>  &#125;<br><br>  <span class="hljs-title function_">handleMouseDown</span>(<span class="hljs-params">e</span>) &#123;<br>    <span class="hljs-keyword">const</span> boom = <span class="hljs-keyword">new</span> <span class="hljs-title class_">Boom</span>(&#123;<br>      <span class="hljs-attr">origin</span>: &#123; <span class="hljs-attr">x</span>: e.<span class="hljs-property">clientX</span>, <span class="hljs-attr">y</span>: e.<span class="hljs-property">clientY</span> &#125;,<br>      <span class="hljs-attr">context</span>: <span class="hljs-variable language_">this</span>.<span class="hljs-property">computerContext</span>,<br>      <span class="hljs-attr">area</span>: &#123;<br>        <span class="hljs-attr">width</span>: <span class="hljs-variable language_">this</span>.<span class="hljs-property">globalWidth</span>,<br>        <span class="hljs-attr">height</span>: <span class="hljs-variable language_">this</span>.<span class="hljs-property">globalHeight</span><br>      &#125;<br>    &#125;)<br>    boom.<span class="hljs-title function_">init</span>()<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">booms</span>.<span class="hljs-title function_">push</span>(boom)<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">running</span> || <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">run</span>()<br>  &#125;<br><br>  <span class="hljs-title function_">handlePageHide</span>(<span class="hljs-params"></span>) &#123;<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">booms</span> = []<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">running</span> = <span class="hljs-literal">false</span><br>  &#125;<br><br>  <span class="hljs-title function_">init</span>(<span class="hljs-params"></span>) &#123;<br>    <span class="hljs-keyword">const</span> style = <span class="hljs-variable language_">this</span>.<span class="hljs-property">renderCanvas</span>.<span class="hljs-property">style</span><br>    style.<span class="hljs-property">position</span> = <span class="hljs-string">&#x27;fixed&#x27;</span><br>    style.<span class="hljs-property">top</span> = style.<span class="hljs-property">left</span> = <span class="hljs-number">0</span><br>    style.<span class="hljs-property">zIndex</span> = <span class="hljs-string">&#x27;999999999999999999999999999999999999999999&#x27;</span><br>    style.<span class="hljs-property">pointerEvents</span> = <span class="hljs-string">&#x27;none&#x27;</span><br><br>    style.<span class="hljs-property">width</span> = <span class="hljs-variable language_">this</span>.<span class="hljs-property">renderCanvas</span>.<span class="hljs-property">width</span> = <span class="hljs-variable language_">this</span>.<span class="hljs-property">computerCanvas</span>.<span class="hljs-property">width</span> = <span class="hljs-variable language_">this</span>.<span class="hljs-property">globalWidth</span><br>    style.<span class="hljs-property">height</span> = <span class="hljs-variable language_">this</span>.<span class="hljs-property">renderCanvas</span>.<span class="hljs-property">height</span> = <span class="hljs-variable language_">this</span>.<span class="hljs-property">computerCanvas</span>.<span class="hljs-property">height</span> = <span class="hljs-variable language_">this</span>.<span class="hljs-property">globalHeight</span><br><br>    <span class="hljs-variable language_">document</span>.<span class="hljs-property">body</span>.<span class="hljs-title function_">append</span>(<span class="hljs-variable language_">this</span>.<span class="hljs-property">renderCanvas</span>)<br><br>    <span class="hljs-variable language_">window</span>.<span class="hljs-title function_">addEventListener</span>(<span class="hljs-string">&#x27;mousedown&#x27;</span>, <span class="hljs-variable language_">this</span>.<span class="hljs-property">handleMouseDown</span>.<span class="hljs-title function_">bind</span>(<span class="hljs-variable language_">this</span>))<br>    <span class="hljs-variable language_">window</span>.<span class="hljs-title function_">addEventListener</span>(<span class="hljs-string">&#x27;pagehide&#x27;</span>, <span class="hljs-variable language_">this</span>.<span class="hljs-property">handlePageHide</span>.<span class="hljs-title function_">bind</span>(<span class="hljs-variable language_">this</span>))<br>  &#125;<br><br>  <span class="hljs-title function_">run</span>(<span class="hljs-params"></span>) &#123;<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">running</span> = <span class="hljs-literal">true</span><br>    <span class="hljs-keyword">if</span> (<span class="hljs-variable language_">this</span>.<span class="hljs-property">booms</span>.<span class="hljs-property">length</span> == <span class="hljs-number">0</span>) &#123;<br>      <span class="hljs-keyword">return</span> <span class="hljs-variable language_">this</span>.<span class="hljs-property">running</span> = <span class="hljs-literal">false</span><br>    &#125;<br><br>    <span class="hljs-title function_">requestAnimationFrame</span>(<span class="hljs-variable language_">this</span>.<span class="hljs-property">run</span>.<span class="hljs-title function_">bind</span>(<span class="hljs-variable language_">this</span>))<br><br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">computerContext</span>.<span class="hljs-title function_">clearRect</span>(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-variable language_">this</span>.<span class="hljs-property">globalWidth</span>, <span class="hljs-variable language_">this</span>.<span class="hljs-property">globalHeight</span>)<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">renderContext</span>.<span class="hljs-title function_">clearRect</span>(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-variable language_">this</span>.<span class="hljs-property">globalWidth</span>, <span class="hljs-variable language_">this</span>.<span class="hljs-property">globalHeight</span>)<br><br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">booms</span>.<span class="hljs-title function_">forEach</span>(<span class="hljs-function">(<span class="hljs-params">boom, index</span>) =&gt;</span> &#123;<br>      <span class="hljs-keyword">if</span> (boom.<span class="hljs-property">stop</span>) &#123;<br>        <span class="hljs-keyword">return</span> <span class="hljs-variable language_">this</span>.<span class="hljs-property">booms</span>.<span class="hljs-title function_">splice</span>(index, <span class="hljs-number">1</span>)<br>      &#125;<br>      boom.<span class="hljs-title function_">move</span>()<br>      boom.<span class="hljs-title function_">draw</span>()<br>    &#125;)<br>    <span class="hljs-variable language_">this</span>.<span class="hljs-property">renderContext</span>.<span class="hljs-title function_">drawImage</span>(<span class="hljs-variable language_">this</span>.<span class="hljs-property">computerCanvas</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-variable language_">this</span>.<span class="hljs-property">globalWidth</span>, <span class="hljs-variable language_">this</span>.<span class="hljs-property">globalHeight</span>)<br>  &#125;<br>&#125;<br><br><br>(<span class="hljs-keyword">function</span> <span class="hljs-title function_">cursorFireworksCusor</span>(<span class="hljs-params"></span>) &#123;<br>  <span class="hljs-keyword">const</span> cursorSpecialEffects = <span class="hljs-keyword">new</span> <span class="hljs-title class_">CursorSpecialEffects</span>()<br>  cursorSpecialEffects.<span class="hljs-title function_">init</span>()<br>&#125;)();<br><br><br></code></pre></td></tr></table></figure>

<p>在<code>_config.fluid.yml</code>引入</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><code class="hljs yaml"><span class="hljs-comment"># 指定自定义 .js 文件路径，支持列表；路径是相对 source 目录，如 /js/custom.js 对应存放目录 source/js/custom.js</span><br><span class="hljs-comment"># Specify the path of your custom js file, support list. The path is relative to the source directory, such as `/js/custom.js` corresponding to the directory `source/js/custom.js`</span><br><span class="hljs-attr">custom_js:</span><br>  <span class="hljs-bullet">-</span> <span class="hljs-string">//cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js</span>  <br>  <span class="hljs-bullet">-</span> <span class="hljs-string">//cdn.jsdelivr.net/gh/metowolf/Metingjs@1.2/dist/Meting.min.js</span> <br>  <span class="hljs-bullet">-</span> <span class="hljs-string">//cdn.bootcss.com/animejs/2.2.0/anime.min.js</span><br>  <span class="hljs-bullet">-</span> <span class="hljs-string">/js/background.js</span><br>  <span class="hljs-bullet">-</span> <span class="hljs-string">/js/fireworks.js</span><br></code></pre></td></tr></table></figure>


                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/categories/%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/" class="category-chain-item">环境配置</a>
  
  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/tags/hexo/" class="print-no-link">#hexo</a>
      
        <a href="/tags/%E8%8A%B1%E9%87%8C%E8%83%A1%E5%93%A8/" class="print-no-link">#花里胡哨</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>fluid主题优化</div>
      <div>http://example.com/2022/03/17/fluid主题优化/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>Feng Zikai</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2022年3月17日</div>
        </div>
      
      
      
        <div class="license-meta-item">
          <div>许可协议</div>
          <div>
            
              
              
                <a class="print-no-link" target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
                  <span class="hint--top hint--rounded" aria-label="BY - 署名">
                    <i class="iconfont icon-by"></i>
                  </span>
                </a>
              
            
          </div>
        </div>
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2022/03/19/%E4%BA%91%E8%AE%A1%E7%AE%97%E4%BD%9C%E4%B8%9A2/" title="云计算作业2">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">云计算作业2</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2022/03/17/%E8%AE%A1%E7%AE%97%E5%B0%8F%E4%BA%8E%E7%AD%89%E4%BA%8EN%E7%9A%84%E8%B4%A8%E6%95%B0%E7%9A%84%E5%B9%B6%E8%A1%8C%E7%AE%97%E6%B3%95/" title="计算小于等于N的质数的并行算法">
                        <span class="hidden-mobile">计算小于等于N的质数的并行算法</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="margin-left: -1rem">
    <div id="toc">
  <p class="toc-header">
    <i class="iconfont icon-list"></i>
    <span>目录</span>
  </p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> <div style="font-size: 0.85rem"> <span id="timeDate">载入天数...</span> <span id="times">载入时分秒...</span> <script src="/js/duration.js"></script> </div> 
    </div>
  
  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.4/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.20.1/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/js/local-search.js" ></script>




  
<script src="//cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script>
<script src="//cdn.jsdelivr.net/gh/metowolf/Metingjs@1.2/dist/Meting.min.js"></script>
<script src="//cdn.bootcss.com/animejs/2.2.0/anime.min.js"></script>



<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
